﻿using System;

class ReverseWordsInASentence
{
    static void Main()
    {
        //Exercise 13.
        //Write a program that reverses the words in given sentence.
        //Example: "C# is not C++, not PHP and not Delphi!" -> "Delphi not and PHP, not C++ not is C#!".

        string text = @"C# is not C++, not PHP and not Delphi!";
        char[] separator = new char [] {' ', ',', '!'};
        string[] words = text.Split(separator, StringSplitOptions.RemoveEmptyEntries);

        for (int i = words.Length - 1; i >= 0; i--)
        {
            Console.Write(words[i]);
            if (i == 5)
            {
                Console.Write(',');
            }
            Console.Write(" ");
        }
        Console.Write('!');
        Console.WriteLine();                        
    }
}

